package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.TestVersionTopic;
import com.yxuan.springboot.service.TestVersionTopicService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zchao
 * TestVersionTopic控制器
 * @date 2023-05-16 14:22:57
 */
@Controller
@Slf4j
@Api(tags = "")
@RequestMapping(value = "/testversiontopic", method = {RequestMethod.POST, RequestMethod.GET})
public class TestVersionTopicController extends BaseController<TestVersionTopic> {

    @Autowired
    private TestVersionTopicService testVersionTopicService;

    //     添加版本题目
    @RequestMapping("/addoptionstotopic")
    @ResponseBody
    public HashMap<String, Object> addOptionsToTopic(@RequestBody Map map) {
        try {
            return testVersionTopicService.addOptionsToTopic(map);
        } catch (Exception e) {
            HashMap<String, Object> result = new HashMap<>();
            log.error(e.getMessage());
            result.put("result", ERROR);
            return result;
        }
    }

    //   TODO  删除版本题目
    @RequestMapping("/deloptionstotopic")
    @ResponseBody
    public HashMap<String, Object> delOptionsToTopic(@RequestBody Map map) throws Exception {
        return testVersionTopicService.delOptionsToTopic(map);
    }
}
